package com.amin.nio;

import java.nio.IntBuffer;
import java.util.Hashtable;
import java.util.LinkedHashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentNavigableMap;

import org.junit.Test;

public class BufferDemo {

	@Test
	public void BufferDemoTest() {
		IntBuffer buf = IntBuffer.allocate(10);
		for (int i = 0; i < buf.capacity(); i++) {
			buf.put(i);
		}
		buf.position(2);
		buf.limit(5);
		IntBuffer sub = null;
		sub = buf.slice();
		for (int i = 0; i < sub.capacity(); i++) {
			int tmp = sub.get(i);
			sub.put(tmp - 1);
		}
		buf.flip();
		buf.limit(buf.capacity());
		while (buf.hasRemaining()) {
			System.out.println(buf.get());
		}
	}
}
